package servlet.rool;

import pojo.Menu;
import service.MenuService;
import service.impl.MenuServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * 修改菜单前的回显的servlet
 */
@WebServlet(value = "/MenuEchoServlet")
public class MenuEchoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String ID=request.getParameter("ID");
        MenuService ms=new MenuServiceImpl();
        Menu menu=ms.queryMenuById(Integer.parseInt(ID));
        List<Menu> menus=ms.querySupMenu();
        request.setAttribute("menu",menu);
        request.setAttribute("menus",menus);
        request.getRequestDispatcher("jsp/yjj/MenuUpdate.jsp").forward(request,response);
    }
    
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 
        doGet(request, response);
    }
}
